package com.kabigon.multiverse.common.valid;

import com.kabigon.multiverse.component.EnumStringValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * @author xu.biao
 * @version v1.0
 * @Package com.kabigon.multiverse.common.valid
 * @data 2022/2/21 0:10
 */
@Documented
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(EnumString.List.class)
@Constraint(validatedBy = EnumStringValidator.class)
public @interface EnumString {

    String message() default "{value not in enum values}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    String[] value();

    @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    public @interface List {
        EnumString[] value();
    }
}
